//
// Created by jsjxsy on 2022/8/17.
//
#include <iostream>
#include <exception>
using namespace std;

struct MyException : public std::exception {
  const char *what() const throw() {
    return "C++ Exception";
  }
};
class MyException2 : public exception {
 public:
  const char *what() const throw() {
    return "C++ Exception2";
  }
};
void test() {
  cout << "test" << endl;
}
int main() {
  try {
    try {
      throw MyException();
    } catch (MyException &e) {
      cout << "MyException caught" << endl;
      cout << e.what() << endl;

      try {
        throw MyException2();
      } catch (MyException2 &e) {
        cout << e.what() << endl;
      }
      throw;
    } catch (exception &e) {
      //其他的错误
      cout << e.what() << endl;
    }
  } catch (MyException2 &e) {
    cout << "out" << endl;
    cout << e.what() << endl;
  } catch (...) {
    cout << "unknown exception" << endl;
  }
  test();
  //test2();
}

void test2() {
  cout << "test2" << endl;
}
